package com.maiji.cloud.entities.login;

import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.maiji.cloud.response.shopingmall.GoodsResData;
import lombok.Data;
import lombok.experimental.Accessors;
import org.eclipse.jetty.util.StringUtil;

/**
 * Description:  功能按钮
 * @author zhanglr  
 * @date 2019年6月12日
 */
@Data
@Accessors(chain=true)
@Table(name = "function_memu")
public class FunctionMemu {

    @TableId
	@Column(name = "uu_id", type = MySqlTypeConstant.VARCHAR, length = 50, isKey = true)
    private String uuId; //主键
	
	@Column(name = "type", type = MySqlTypeConstant.VARCHAR, length = 50)
	private String type; //类型
	
	@Column(name = "icon", type = MySqlTypeConstant.VARCHAR, length = 255)
	private String icon; //图标地址
	
	@Column(name = "status", type = MySqlTypeConstant.INT, length = 2)
	private String status; //状态0：正常，1删除
	
	@Column(name = "title", type = MySqlTypeConstant.VARCHAR, length = 50)
	private String title; //标题
	
	@Column(name = "skip", type = MySqlTypeConstant.VARCHAR, length = 50)
	private String skip; //标题
	
	@Column(name = "web_url", type = MySqlTypeConstant.VARCHAR)
	private String webUrl; //跳转的web地址
	
	@Column(name = "url", type = MySqlTypeConstant.VARCHAR)
	private String url; //图片地址
	
	@Column(name = "bg_image", type = MySqlTypeConstant.VARCHAR)
	private String bgImage; //封面图

	@TableField(exist = false)
	private String imgId; //图片ID

	@TableField(exist = false)
	private GoodsResData goods; //关联商品

	@TableField(exist = false)
	private String goodsId; //关联商品ID

    public String getGoodsId() {
        if (StringUtil.isNotBlank(webUrl) && webUrl.contains("goodsId="))
            return webUrl.substring(webUrl.indexOf("goodsId=") + 8);
        return null;
    }

}
